﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;
namespace Server_NhaSach.BusinessLayer
{
    public class CTDatHangNCCBlo
    {
        #region "Khai báo các biến"
        private CTDatHangNCCDAO da;
        private CTDatHangNCCDTO _CTDHNCC;
        private string _error;
        #endregion

        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public CTDatHangNCCDTO CTDHNCC
        {
            get { return _CTDHNCC; }
            set { _CTDHNCC = value; }
        }
        #endregion

        #region "Khai báo các Method"
        public CTDatHangNCCBlo()
        {
            _CTDHNCC = new CTDatHangNCCDTO();
            da = new CTDatHangNCCDAO();
        }
        public bool InsertCTDHNCC(string maMH, string maDHNCC, int soLuong, string dVT, double donGia, float chietKhau, double thanhTien, bool daGiao)
        {
            CTDHNCC = new CTDatHangNCCDTO(maMH, maDHNCC, soLuong, dVT, donGia, chietKhau, thanhTien, daGiao);
            if (!da.InsertCTDHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdateCTDHNCC(string maMH, string maDHNCC, int soLuong, string dVT, double donGia, float chietKhau, double thanhTien, bool daGiao)
        {
            CTDHNCC = new CTDatHangNCCDTO(maMH, maDHNCC, soLuong, dVT, donGia, chietKhau, thanhTien, daGiao);
            if (!da.UpdateCTDHNCC(CTDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeleteCTDHNCC(string MaMH, string maDHNCC)
        {
            if (!da.DeleteCTDHNCC(MaMH, maDHNCC))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_CTDatHangNCC()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_CTDHNCC();
            return ds;
        }
        #endregion
    }
}